home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F35058_maximum.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  2.4 KB  |  65 lines

  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:saxon="http://icl.com/saxon"
  4. xmlns:maximum-pick-bigger="f:maximum-pick-bigger"
  5. xmlns:maximum-own-compare="f:maximum-own-compare"
  6. exclude-result-prefixes="xsl saxon maximum-own-compare maximum-pick-bigger"
  7. >
  8.    <xsl:import href="foldl.xsl"/>
  9.  
  10.    <maximum-pick-bigger:maximum-pick-bigger/>
  11.    <maximum-own-compare:maximum-own-compare/>
  12.  
  13.     <xsl:template name="maximum">
  14.       <xsl:param name="pList" select="/.."/>
  15.       <xsl:param name="pCMPFun" select="/.."/>
  16.  
  17.       <xsl:variable name="vdfCMPFun" select="document('')/*/maximum-own-compare:*[1]"/>
  18.       <xsl:variable name="vFoldFun" select="document('')/*/maximum-pick-bigger:*[1]"/>
  19.    
  20.       <xsl:if test="$pList">
  21.           <xsl:variable name="vCMPFun" select="$pCMPFun | $vdfCMPFun[not($pCMPFun)]"/>
  22.           <xsl:variable name="vFuncList">
  23.             <xsl:copy-of select="$vFoldFun"/> <!-- Pick Bigger -->
  24.             <xsl:copy-of select="$vCMPFun"/>  <!-- Compare -->
  25.           </xsl:variable>
  26.  
  27.           <xsl:call-template name="foldl">
  28.             <xsl:with-param name="pFunc" select="saxon:node-set($vFuncList)/*"/>
  29.             <xsl:with-param name="pList" select="$pList"/>
  30.             <xsl:with-param name="pA0" select="$pList[1]"/>
  31.           </xsl:call-template>
  32.       </xsl:if>
  33.     </xsl:template>
  34.  
  35.     <xsl:template name="pickBigger" match="maximum-pick-bigger:*">
  36.          <xsl:param name="arg0"/>
  37.          <xsl:param name="arg1"/>
  38.          <xsl:param name="arg2"/>
  39.  
  40.          <xsl:variable name="vIsGreater">
  41.            <xsl:apply-templates select="$arg0">
  42.              <xsl:with-param name="arg1" select="$arg1"/>
  43.              <xsl:with-param name="arg2" select="$arg2"/>
  44.            </xsl:apply-templates>
  45.          </xsl:variable>
  46.          <xsl:choose>
  47.            <xsl:when test="$vIsGreater = 1">
  48.              <xsl:copy-of select="$arg1"/>
  49.            </xsl:when>
  50.            <xsl:otherwise>
  51.              <xsl:copy-of select="$arg2"/>
  52.            </xsl:otherwise>
  53.          </xsl:choose>
  54.     </xsl:template>
  55.  
  56.     <xsl:template name="isGreaterDefault" match="maximum-own-compare:*">
  57.          <xsl:param name="arg1"/>
  58.          <xsl:param name="arg2"/>
  59.  
  60.          <xsl:choose>
  61.           <xsl:when test="$arg1 > $arg2">1</xsl:when>
  62.           <xsl:otherwise>0</xsl:otherwise>
  63.          </xsl:choose>
  64.     </xsl:template>
  65. </xsl:stylesheet>